<?php namespace Cy\Controller;

class OrdersController extends \Hdphp\Controller\Controller{
	public function index(){
		$_GET['wxid'] =isset($_GET['wxid'])?$_GET['wxid']:$_SESSION['wxid'];
		$_SESSION['wxid'] = $_GET['wxid'];
		$data = Db::table('shop')->where('wxid',$_GET['wxid'])->get();
		View::with('data',$data)->make();
	}
	
	public function orderInfo(){
		
		$dpid = Q('dpid');

		$data = Db::table('shop_order')->where('dpid',$dpid)->orderBy('book_time','desc')->get();
		$goods = Db::table('shop_goods')->get();

		foreach ($data as $key => $value) {
			
			$data[$key]['goods'] = unserialize($value['goods']);
		
			foreach ($data[$key]['goods']['data'] as $k => $v) {
//				if($v==0)
//				{
//					unset($data[$key]['goods']['data'][$k]);
//					continue;
//				}
				$data[$key]['goods']['data'][$k] = Db::table('shop_goods')->where('id',$k)->first();
				$data[$key]['goods']['data'][$k]['num'] = $v;
			}
			
		}

		View::with('goods',$goods);
		View::with('data',$data)->make();
	}
	
	
	
	
}













